{extend name="./base" /}

{block name="body"}
<form class="layui-form model-form" id="thisForm">
	<fieldset class="layui-elem-field layui-field-title">
		<legend>基础设置</legend>
	</fieldset>
	<div class="layui-form-item">
		<label class="layui-form-label layui-form-required">小程序名称</label>
		<div class="layui-input-block">
			<input name="form[name]" class="layui-input" lay-verify="required" value="{$data['name'] ?? ''}"/>
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label layui-form-required">原始ID</label>
		<div class="layui-input-block">
			<input name="form[original_id]" class="layui-input" value="{$data['original_id'] ?? ''}"/>
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label layui-form-required">APPID</label>
		<div class="layui-input-block">
			<input name="form[appid]" class="layui-input" lay-verify="required" value="{$data['appid'] ?? ''}"/>
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label layui-form-required">APPSECRET</label>
		<div class="layui-input-block">
			<input name="form[key]" class="layui-input" lay-verify="required" value="{$data['key'] ?? ''}"/>
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">二维码</label>
		{:tpl_upload_image(@$data['qrcode'], 'form[qrcode]')}
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">多图上传</label>
		{:tpl_upload_image_multi(@$data['pic'], 'form[pic][]')}
	</div>

	<div class="layui-form-item">
		<div class="layui-input-block">
			<button class="layui-btn" lay-filter="formSubmit" lay-submit>保存</button>
			<button class="layui-btn layui-btn-primary" type="reset" >重置</button>
		</div>
	</div>
</form>
{/block}

{block name="script"}
<script>
	layui.use(['layer', 'form', 'table', 'upload'], function () {
		let $ = layui.jquery, form= layui.form;

		// 表单提交
		form.on('submit(formSubmit)', function (data) {
			let formData = data.field;
			$.post('/admin/wechatapp/config', formData, function(res){
				layer.msg('编辑成功', {time: 1000}, function(){
					window.location.href = '/admin/wechatapp/config';
				})
			})
			return false;
		});
	})
</script>
{/block}